package com.zd.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zd.error.BaseException;
import com.zd.vo.Address;
import com.zd.vo.Person;

@Controller
public class ListController extends BaseController{
	
	@RequestMapping(value="/hello")
	@ResponseBody
	public String Hello() throws BaseException{
		try{
			int result = 5/0;
		}catch(Exception e){
			throw new BaseException("500", "0不能做除数");
		};
		
		return "hello ytt";
	}
	@RequestMapping(value="/array1")
	@ResponseBody
	public Address Array1(Address address){
		Address ad1 = new Address();
		ad1.setProvience(address.getProvience());
		ad1.setCity(address.getCity());
		return ad1;
	}
	
	@RequestMapping(value="/getperson")
	@ResponseBody
	public Person GetPerson(Person person){
		
		return person;
	}
	@RequestMapping("/json1")
	public @ResponseBody Address Json1(@RequestBody Address address){
//	public @ResponseBody Address Json1(Address address){
		System.out.println(address.toString());
		
		Address address1 = new Address();
		address1.setCity("济宁市");
		address1.setProvience("山东省");
		return address;
	}
	@RequestMapping("/list")
	public String list(){
		return "list";
	}
}
